<cfsilent>
<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: userForm.cfm 842 2006-07-04 16:18:58Z mpwoodward $

Notes:
TODO: Figure out how to do validation with qforms against FCK
--->
</cfsilent>
<cfoutput>
<!--- <script type="text/javascript">
	function deleteUser(userId) {
		var msg = "#getProperty('resourceBundleService').getResourceBundle().getResource('deleteuserconfirm')#";
		if (confirm(msg)) {
			location.replace("index.cfm?#getProperty('eventParameter')#=deleteUser&userId=" + userId);
		}
	}
</script> --->

<h3>
<cfif user.getUserId() EQ "">
	#getProperty("resourceBundleService").getResourceBundle().getResource("createuser")#
<cfelse>
	#getProperty("resourceBundleService").getResourceBundle().getResource("updateuser")#
</cfif>
</h3>

<cfif IsDefined("message")>
	<p style="color:red;">#variables.message#</p>
</cfif>

<form name="userForm" action="index.cfm?#getProperty('eventParameter')#=processUserForm" method="post">
	<table border="0" cellpadding="2" cellspacing="1" width="100%">
		<tr>
			<td>* #getProperty("resourceBundleService").getResourceBundle().getResource("email")#</td>
			<td>
				<input type="text" name="email" size="30" maxlength="100" value="#variables.user.getEmail()#" />
			</td>
		</tr>
		<tr>
			<td><cfif variables.user.getUserId() EQ "">* </cfif>#getProperty("resourceBundleService").getResourceBundle().getResource("password")#</td>
			<td>
				<input type="password" name="password" size="10" maxlength="10" />
			</td>
		</tr>
		<tr>
			<td><cfif variables.user.getUserId() EQ "">* </cfif>#getProperty("resourceBundleService").getResourceBundle().getResource("confirmpassword")#</td>
			<td>
				<input type="password" name="confirmPassword" size="10" maxlength="10" />
			</td>
		</tr>
		<cfif variables.user.getUserId() NEQ "">
			<tr>
				<td>&nbsp;</td>
				<td>#getProperty("resourceBundleService").getResourceBundle().getResource("userupdatepasswordmessage")#</td>
			</tr>
		</cfif>
		<tr>
			<td>* #getProperty("resourceBundleService").getResourceBundle().getResource("firstname")#</td>
			<td>
				<input type="text" name="firstName" size="30" maxlength="50" value="#variables.user.getFirstName()#" />
			</td>
		</tr>
		<tr>
			<td>* #getProperty("resourceBundleService").getResourceBundle().getResource("lastname")#</td>
			<td>
				<input type="text" name="lastName" size="30" maxlength="50" value="#variables.user.getLastName()#" />
			</td>
		</tr>
		<tr>
			<td>* #getProperty("resourceBundleService").getResourceBundle().getResource("active")#</td>
			<td>
				<input type="checkbox" name="isActive" value="1"<cfif variables.user.getAudit().getIsActive() EQ 1> checked</cfif> />
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input type="submit" class="button" name="submit" value="<cfif user.getUserId() EQ ''>#getProperty('resourceBundleService').getResourceBundle().getResource('createuser')#<cfelse>#getProperty('resourceBundleService').getResourceBundle().getResource('updateuser')#</cfif>" />&nbsp;
				<!--- <cfif user.getUserId() NEQ "">
					<input type="button" name="delete" value="#getProperty('resourceBundleService').getResourceBundle().getResource('deleteuser')#" 
						onClick="javascript:deleteUser('#variables.user.getUserId()#');" />&nbsp;
				</cfif> --->
				<input type="button" class="button" name="cancel" value="#getProperty('resourceBundleService').getResourceBundle().getResource('cancel')#" 
						onClick="javascript:history.back();" />
			</td>
		</tr>
	</table>
	
	<input type="hidden" name="userId" value="#variables.user.getUserId()#" />
</form>

<script type="text/javascript">
	// form validation
	objForm = new qForm("userForm");

	// set required fields and do additional validation
	objForm.email.required = true;
	objForm.email.validateEmail();
	objForm.email.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('email')#";
	objForm.password.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('password')#";
	objForm.confirmPassword.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('confirmpassword')#";
<cfif variables.user.getUserId() EQ "">
	objForm.password.required = true;
	objForm.password.validateNotEmpty();
	objForm.confirmPassword.required = true;
	objForm.confirmPassword.validateNotEmpty();
</cfif>
	objForm.password.validateSame("confirmPassword");
	objForm.firstName.required = true;
	objForm.firstName.validateNotEmpty();
	objForm.firstName.description = "#getProperty('resourceBundleService').getResourceBundle().getResource('firstname')#";
	objForm.lastName.required = true;
	objForm.lastName.validateNotEmpty();
	objForm.lastName.descrption = "#getProperty('resourceBundleService').getResourceBundle().getResource('lastname')#";
</script>
</cfoutput>